
import random

WIDTH = 250
HEIGHT = 250

BACK_COLOR = (0, 0, 0)

class MyRect:
    def __init__(self, x, y, w, h, clr):
        self.x = x
        self.y = y
        self.w = w
        self.h = h
        self.clr = clr

    def GetGridPos(self):
        gx = self.x // self.w
        gy = self.y // self.h

        return gx, gy

    def Draw(self):
        rc = Rect((self.x - self.w // 2, self.y - self.h // 2), (self.w, self.h))
        screen.draw.filled_rect(rc, self.clr)

rc_list = []
unit = 50

def round_num(n):
    m=[]
    for i in range(0,n):
        a=[]
        for j in range(0,n):
            a.append(0)
        m.append(a)
    left_top=0
    right_buttom=n-1
    number=10
    while left_top<right_buttom:
        i=left_top
        while i<right_buttom:
            m[left_top][i]=number
            i+=1
            number+=10
        i=left_top
        while i<right_buttom:
            m[i][right_buttom]=number
            i+=1
            number+=10
        i=right_buttom
        while i>left_top:
            m[right_buttom][i]=number
            i-=1
            number+=10
        i=right_buttom
        while i>left_top:
            m[i][left_top]=number
            i-=1
            number+=10
        left_top+=1
        right_buttom-=1
    if( n%2 !=0):
        m[n//2][n//2]=n*n*10
    return m
def Output(n):
    m=round_num(n)
    print(m)
    for y in range(0,n):
        for x in range(0,n):
            red=m[x][y]
            clr=(red,0,0)
            Rect=MyRect(y*unit+unit//2,x*unit+unit//2,unit,unit,clr)
            rc_list.append(Rect)

Output(WIDTH//unit)

def on_key_down(key):
    if key == keys.ESCAPE:
        quit()
        
def on_mouse_down(pos):
    x = pos[0]
    y = pos[1]
    gx = x // unit
    gy = y // unit


def on_mouse_up(pos):
    pass 

def update():
    pass
        
def draw():
    screen.clear()
    screen.fill(BACK_COLOR)
    for rc in rc_list:
        rc.Draw()


